/**
 * jquery ajax的封装, post方式
 * @param url
 * @param dataParams
 * @param successCall
 * @param async
 */
function postAjax(url, dataParams, successCall, async) {
    ajax(url, "POST", dataParams, successCall, async);
}

/**
 * jquery ajax的封装, get方式
 * @param url
 * @param dataParams
 * @param successCall
 * @param async
 */
function getAjax(url, dataParams, successCall, async) {
    ajax(url, "GET", dataParams, successCall, async);
}

/**
 * jquery ajax
 * @param url
 * @param type
 * @param dataParams
 * @param successCall
 * @param async
 */
function ajax(url, type, dataParams, successCall, async) {
    if (!successCall) {
        successCall = dataParams;
    }
    $.ajax({
        async: async,
        type: type,
        url: url,
        data: successCall ? dataParams : {},
        dataType: "json",
        success: successCall,
        error: ajaxError
    });
}

/**
 *
 * @param url
 * @param type
 * @param dataParams
 * @param successCall
 * @param async
 */
function ajaxBody(url, type, dataParams, successCall, async) {
    $.ajax({
        async: async,
        type: type,
        url: url,
        contentType: "application/json",
        data: JSON.stringify(dataParams),
        dataType: "json",
        success: successCall,
        error: ajaxError
    });
}

/**
 * jquery ajax抛出异常时的回调
 * @param resp
 */
function ajaxError(resp) {
    layer.closeAll();
    layer.alert('出现异常: ' + resp.status, {icon: 2});
    console.log(resp);
}